﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Demo_HHT_EARTH
{
    public partial class DLflight : Form
    {
        WebPor.Service1 con = new WebPor.Service1();
        DataSet dataEmp = new DataSet();
        DataSet dsGetflight = new DataSet();
        DataSet dataEq = new DataSet();
        String flight_no,status_flight = string.Empty;
        DateTime flight_date;
        public DLflight()
        {
            InitializeComponent();
            radioButton1.Checked = true;
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            DownloadFld();
            
           
        }

        private void DownloadFld()
        {
            con.Url = string.Format("http://192.168.1.220/WebAppPor01/Service1.asmx");
            flight_no = Flight_no.Text;
            flight_date = dateTimePicker1.Value;
            string sfltD = string.Format("{0:M/d/yyyy}", flight_date);
            /// string sfltD = Convert.ToString(flight_date);
            //dsGetflight = con.usp_GetFlight("EARTHHHT", "EK9999", sfltD, "A", "ERP", "My pda");
            // dataEmp = con.DownloadFlightEmp(flight_no, flight_date);
            dsGetflight = con.usp_GetFlight(Demo_HHT_EARTH.GobalVariableEARTH.ApplicationID,
                flight_no,
                sfltD,
                status_flight,
                Demo_HHT_EARTH.GobalVariableEARTH.UserDevice,
                Demo_HHT_EARTH.GobalVariableEARTH.UserID);
            dataEmp = con.usp_GetFlightEmployees("EarthHHT", 9999, "", "", "BOTH", "", "", "", "");
            dataEq = con.usp_GetFlightEquipment("EarthHHT", 2003, "EA", "1005", "BOTH", "", "", "My PC", "ERP");
            if (dsGetflight == null || dataEmp == null || dataEq == null || flight_no == string.Empty)
            {
                label3.Visible = true;
                label3.Text = "Data Not Found";
            }
            else
            {
                // MessageBox.Show("OK");
                // this.Close();
                // Demo_HHT_EARTH.DLflight2 dl2 = new DLflight2(dataEmp,flight_no);
                Demo_HHT_EARTH.GobalVariableEARTH.flight_status = status_flight;
                Demo_HHT_EARTH.DLflightInfo dl2 = new DLflightInfo(dsGetflight, dataEmp, dataEq, flight_no); //(dsGetflight,dataEmp,dataEq, flight_no)
                dl2.Show();
            }
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            this.Close();
            DEMO_TEMP1.MainMenu dm = new DEMO_TEMP1.MainMenu(true,1);
            dm.Show();
            
        }

        private void Download_Click(object sender, EventArgs e)
        {

            DownloadFld();
           
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                radioButton2.Checked = false;
                radioButton3.Checked = false;
                status_flight = "Arrival";

            }
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked)
            {
                radioButton1.Checked = false;
                radioButton3.Checked = false;
                status_flight = "Departure";

            }
        }

        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton3.Checked)
            {
                radioButton2.Checked = false;
                radioButton1.Checked = false;
                status_flight = "Both";
                

            }
        }

    }
}